import { BasicColumn, FormSchema } from "/@/components/Table"
import { render } from "/@/utils/common/renderUtils"

export const columns: BasicColumn[] = [
  {
    title: "名称",
    width: 150,
    dataIndex: "name",
  },
  {
    title: "文章数",
    width: 100,
    dataIndex: "articleNum",
  },
  {
    title: "排序",
    width: 60,
    dataIndex: "sortNo",
  },
  {
    title: "状态",
    dataIndex: "status",
    width: 60,
    customRender: ({ text }) => {
      const color = text == "2" ? "red" : text == "1" ? "green" : "gray"
      return render.renderTag(render.renderDict(text, "article_status"), color)
    },
  },
  {
    title: "创建者",
    width: 110,
    dataIndex: "createdBy",
  },
  {
    title: "创建时间",
    width: 160,
    dataIndex: "createdAt",
  },
  {
    title: "更新时间",
    width: 160,
    dataIndex: "updatedAt",
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "名称",
    component: "Input",
  },
]

export const formSchema: FormSchema[] = [
  {
    field: "id",
    label: "id",
    component: "Input",
    show: false,
  },
  {
    field: "name",
    label: "名称",
    component: "Input",
    required: true,
    componentProps: {
      placeholder: "请输入名称",
    },
  },
  {
    field: "status",
    label: "状态",
    required: true,
    component: "JDictSelectTag",
    defaultValue: "1",
    componentProps: {
      type: "radio",
      dictType: "article_status",
    },
  },
  {
    field: "sortNo",
    label: "排序",
    component: "InputNumber",
    componentProps: {
      size: "middle",
      style: {
        width: "100%",
      },
    },
  },
  {
    field: "remark",
    label: "摘要",
    component: "InputTextArea",
  },
]
